home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PASCAL / 0193.ZIP / THELP.PAS < prev    next >
Pascal/Delphi Source File  |  1986-02-06  |  33KB  |  874 lines

  1. R
  2. { Program THELP was written by a Mr. Glenn Wood of the Greenville PC Club of
  3. Greenville, Texas.  Mr. Wood learned the principles demonstrated in this
  4. program in a class taught by Mr. Stephen R. Davis, also of Greenville.
  5.   One suggestion for a way to improve this program can be inferred from Mr.
  6. Davis's own comment about the program in a letter he wrote to Borland
  7. International: "Note that the window opening is slow because in our class we
  8. insisted on using the BIOS interrupt rather than go directly to screen memory
  9. ourselves."                                                              }
  10.  
  11. PROGRAM THELP;
  12.  
  13. {$C-}
  14. {$K-}
  15.  
  16.  
  17. {VARIABLE SECTION FOR 'THELP'}
  18.  
  19. type
  20.   text80          = string[80];
  21.   RegType         = record
  22.                       ax,bx,cx,dx,bp,si,di,ds,es,flags:integer
  23.                     end;
  24.   HalfRegType     = record
  25.                       al,ah,bl,bh,cl,ch,dl,dh:byte
  26.                     end;
  27.   IntrType        = record
  28.                       ip,cs : integer
  29.                     end;
  30.  
  31. const
  32.   EntryChar       = 19;                { ALT 'R' }
  33.   Escape          = 0;
  34.   FirstRow        = 3;
  35.   FirstCol        = 11;
  36.   WindowWidth     = 60;
  37.   WindowLength    = 18;
  38.   Dr              = 3;
  39.   Mr              = 12;
  40.   Cr              = $0D;
  41.   UserInt         = $66;
  42.   KybdInt         = $16;
  43.   ProgSize : integer = $A000;             { approx. program size }
  44.  
  45.   Regs    : regtype = (ax:0;bx:0;cx:0;dx:0;bp:0;si:0;di:0;ds:0;es:0;flags:0);
  46.   SaveDS  :integer  = 0;
  47.  
  48. var
  49.   SaveReg    : RegType;
  50.   SaveHalf   : HalfRegType absolute SaveReg;
  51.   HalfReg    : HalfRegType absolute regs;
  52.   i,j,x,y    : integer;
  53.   CursorPos  : integer;
  54.   Selection  : integer;
  55.   savebuf    : array[1..windowwidth] of array[1..windowlength] of integer;
  56.  
  57.  
  58. { MISC. PROCEDURES AND FUNTIONS FOR THELP }
  59.  
  60. procedure Bright(line:text80);
  61. begin
  62.   textcolor(15);
  63.   write(line);
  64.   textcolor(7);
  65. end;
  66.  
  67. procedure PrintHeading;
  68. begin
  69.   bright('T');       write('URBO Pascal ');
  70.   bright('Help   ');  write('Ver 2.0');
  71. end;
  72.  
  73. procedure PrintMCS;
  74. begin
  75.   bright('M'); write('agnum ');
  76.   bright('C'); write('ustom ');
  77.   bright('S'); write('oftware');
  78. end;
  79.  
  80. procedure Border;
  81. begin
  82.    GotoXY(1,1);                              {clear the window now}
  83.    Write(chr(218));
  84.    for i:=2 to windowwidth-1 do Write(chr(196));
  85.    Write(chr(191));
  86.    for i:=2 to windowlength-1 do
  87.    begin
  88.       GotoXY(1, i);  Write(chr(179));
  89.       for j := 2 to windowwidth-1 do
  90.          Write(' ');
  91.       GotoXY(windowwidth, i);  Write(chr(179));
  92.    end;
  93.    GotoXY(1, windowlength);
  94.    Write(chr(192));
  95.    for i:=2 to windowwidth-1 do Write(chr(196));
  96.    Write(chr(217));
  97. END;
  98.  
  99. function GetScreenChar:integer;
  100. begin
  101.    savereg.ax := $0800;                 {9 -> get character/attr @ cursor}
  102.    savereg.bx := 0;
  103.    Intr($10,savereg);
  104.    GetScreenChar := savereg.ax
  105. end;
  106.  
  107. procedure PutScreenChar(input:integer);
  108. begin
  109.    savereg.ax := $0900 + (input and $FF); {a -> put character/attr @ cursor}
  110.    savereg.bx := input shr 8;          {put the attrib in bl and 0 in bh}
  111.    savereg.cx := 1;
  112.    Intr($10,savereg)
  113. end;
  114.  
  115. procedure OpenWindow;
  116. begin
  117.   window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
  118.     for j := 1 to windowlength do
  119.       for i := 1 to windowwidth do
  120.       begin
  121.          GoToXY(i,j);
  122.          savebuf[i][j] := GetScreenChar      {get a attribute/character at the cursor}
  123.       end;
  124.    border;
  125.   window (firstcol+1,firstrow+1,firstcol+windowwidth-2,firstrow+windowlength-2);
  126.   gotoxy(1,1);
  127. end;
  128.  
  129. procedure closewindow;
  130. begin
  131.   window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
  132.   for j := 1 to windowlength do
  133.     for i := 1 to windowwidth do
  134.       begin
  135.          GoToXY(i,j);
  136.          PutScreenChar(savebuf[i][j])
  137.       end
  138. end;
  139.  
  140.  
  141. { MENU PRINT PROCEDURES FOR THELP }
  142.  
  143. procedure PrintMenu(number:integer);
  144. begin
  145.   case number of
  146.     0  : begin
  147.            gotoxy(mr+3,2);   PrintHeading;
  148.            gotoxy(mr+7,3);   PrintMCS;
  149.            gotoxy(mr+12,5);  write('MAIN MENU');
  150.            gotoxy(mr,6);   write('<1> Edit Commands');
  151.            gotoxy(mr,7);   write('<2> Syntax Structure');
  152.            gotoxy(mr,8);   write('<3> Standard Procedures/Functions');
  153.            gotoxy(mr,9);   write('<4> Compiler Directives');
  154.            gotoxy(mr,10);  write('<5> Runtime Errors');
  155.            gotoxy(mr,11);  write('<6> I/O Errors');
  156.            gotoxy(mr,12);  write('<7> Standard Identifiers');
  157.            gotoxy(mr,13);  write('<8> Version 2 Additions Part I');
  158.            gotoxy(mr,14);  write('<9> Version 2 Additions Part II');
  159.          end;
  160.     1  : begin
  161.            gotoxy(mr+3,2);   PrintHeading;
  162.            gotoxy(mr+7,3);   PrintMCS;
  163.            gotoxy(mr+7,5);   write('EDITOR COMMANDS MENU');
  164.            gotoxy(mr,7);   write('<1> Cursor Movements Part I');
  165.            gotoxy(mr,8);   write('<2> Cursor Movements Part II');
  166.            gotoxy(mr,9);   write('<3> Insert and Delete Commands');
  167.            gotoxy(mr,10);  write('<4> Block Commands');
  168.            gotoxy(mr,11);  write('<5> Miscellaneous and Options');
  169.          end;
  170.  
  171.     2  : begin
  172.            gotoxy(mr+3,2);   PrintHeading;
  173.            gotoxy(mr+7,3);   PrintMCS;
  174.            gotoxy(mr+6,5);   write('SYNTAX STRUCTURE MENU');
  175.            gotoxy(mr,6);   write('<1> TYPE');
  176.            gotoxy(mr,7);   write('<2> CONST');
  177.            gotoxy(mr,8);   write('<3> VAR');
  178.            gotoxy(mr,9);   write('<4> WITH DO and CASE');
  179.            gotoxy(mr,10);  write('<5> REPEAT UNTIL and WHILE DO');
  180.            gotoxy(mr,11);  write('<6> IF THEN ELSE and FOR TO DO');
  181.            gotoxy(mr,12);  write('<7> PROGRAM, PROCEDURE and FUNCTION');
  182.            gotoxy(mr,13);  write('<8> Program Structure');
  183.          end;
  184.  
  185.     3  : begin
  186.            gotoxy(mr+3,2);   PrintHeading;
  187.            gotoxy(mr+7,3);   PrintMCS;
  188.            gotoxy(mr,5);   write('STANDARD PROCEDURES/FUNCTIONS MENU');
  189.            gotoxy(mr,6);   write('<1> Input/Output Procedures');
  190.            gotoxy(mr,7);   write('<2> Arithmetic Functions');
  191.            gotoxy(mr,8);   write('<3> Scalar Functions/Heap Control');
  192.            gotoxy(mr,9);   write('<4> String Procedures and Functions');
  193.            gotoxy(mr,10);  write('<5> File Handling Procedures');
  194.            gotoxy(mr,11);  write('<6> File Handling Functions');
  195.            gotoxy(mr,12);  write('<7> Transfer/Screen Procs & Funcs');
  196.            gotoxy(mr,13);  write('<8> Miscellaneous Proc/Func Part I');
  197.            gotoxy(mr,14);  write('<9> Miscellaneous Functions Part II');
  198.          end;
  199.   end;
  200.   repeat
  201.     gotoxy(19,15);  write('Enter Selection  ? ');
  202.     savereg.ax := $00;
  203.     Intr(userint,savereg);
  204.     selection := savehalf.ah - 1;
  205.   until ((selection in [0..9]) and (number in [0,3]))
  206.      or ((selection in [0..5]) and (number = 1))
  207.      or ((selection in [0..8]) and (number = 2));
  208.   clrscr;
  209. end;
  210.  
  211.  
  212. procedure Wait;
  213. begin
  214.   gotoxy(14,16); write('PRESS <ESC> TO RETURN TO MENU');
  215.   repeat
  216.     savereg.ax := 0;
  217.     Intr(userint,savereg);
  218.   until savehalf.ah = $01;
  219.   clrscr;
  220. end;
  221.  
  222. procedure CursorMoveI;
  223. begin
  224.   gotoxy(dr,2);   write('CURSOR MOVEMENTS  Part I :');
  225.   gotoxy(dr,4);   write('  Character left         Ctrl-S  ->   ',#$1B);
  226.   gotoxy(dr,5);   write('    Alternative          Ctrl-H  ->  ');
  227.   gotoxy(dr,6);   write('  Character right        Ctrl-D  ->   ',#$1A);
  228.   gotoxy(dr,7);   write('  Word left              Ctrl-A  ->  Ctrl ',#$1B);
  229.   gotoxy(dr,8);   write('  Word right             Ctrl-F  ->  Ctrl ',#$1A);
  230.   gotoxy(dr,9);   write('  Line up                Ctrl-E  ->   ',#$18);
  231.   gotoxy(dr,10);  write('  Line down              Ctrl-X  ->   ',#$19);
  232.   gotoxy(dr,11);  write('  Scroll up              Ctrl-W  ->  ');
  233.   gotoxy(dr,12);  write('  Scroll down            Ctrl-Z  ->  ');
  234.   gotoxy(dr,13);  write('  Page up                Ctrl-R  ->  PgUp');
  235.   gotoxy(dr,14);  write('  Page down              Ctrl-C  ->  PgDn');
  236.   Wait;
  237. end;
  238.  
  239. procedure CursorMoveII;
  240. begin
  241.   gotoxy(dr,2);   write('CURSOR MOVEMENTS  Part II :');
  242.   gotoxy(dr,4);   write('  To left on line      Ctrl-Q Ctrl-S  ->  Home');
  243.   gotoxy(dr,5);   write('  To right on line     Ctrl-Q Ctrl-D  ->  End');
  244.   gotoxy(dr,6);   write('  To top of page       Ctrl-Q Ctrl-E  ->  Ctrl Home');
  245.   gotoxy(dr,7);   write('  To bottom of page    Ctrl-Q Ctrl-X  ->  Ctrl End');
  246.   gotoxy(dr,8);   write('  To top of file       Ctrl-Q Ctrl-R  ->  Ctrl PgUp');
  247.   gotoxy(dr,9);   write('  To end of file       Ctrl-Q Ctrl-C  ->  Ctrl PgDn');
  248.   gotoxy(dr,10);  write('  To top of block      Ctrl-Q Ctrl-B  ->  ');
  249.   gotoxy(dr,11);  write('  To end of block      Ctrl-Q Ctrl-K  ->  ');
  250.   gotoxy(dr,12);  write('  To last cur.pos.     Ctrl-Q Ctrl-P  ->  ');
  251.   Wait;
  252. end;
  253.  
  254. procedure InsertDelete;
  255. begin
  256.   gotoxy(dr,2);   write('INSERT and DELETE :');
  257.   gotoxy(dr,4);   write('  Insert mode on/off     Ctrl-V         ->  Ins');
  258.   gotoxy(dr,5);   write('  Insert line            Ctrl-N         ->  ');
  259.   gotoxy(dr,6);   write('  Delete line            Ctrl-Y         ->  ');
  260.   gotoxy(dr,7);   write('  Del to end of line     Ctrl-Q Ctrl-Y  ->  ');
  261.   gotoxy(dr,8);   write('  Delete right word      Ctrl-T         ->  ');
  262.   gotoxy(dr,9);   write('  Del char under cursor  Ctrl-G         ->  Del');
  263.   gotoxy(dr,10);  write('  Delete left character  <DEL>          ->  ');
  264.   gotoxy(dr,11);  write('    Alternative          nothing        ->  ');
  265.   Wait;
  266. end;
  267.  
  268. procedure BlockCommands;
  269. begin
  270.   gotoxy(dr,2);   write('BLOCK COMMANDS :');
  271.   gotoxy(dr,4);   write('  Mark block begin       Ctrl-K Ctrl-B  ->  F7');
  272.   gotoxy(dr,5);   write('  Mark block end         Ctrl-K Ctrl-K  ->  F8');
  273.   gotoxy(dr,6);   write('  Mark single word       Ctrl-K Ctrl-T  ->  ');
  274.   gotoxy(dr,7);   write('  Hide/display block     Ctrl-K Ctrl-H  ->  ');
  275.   gotoxy(dr,8);   write('  Copy block             Ctrl-K Ctrl-C  ->  ');
  276.   gotoxy(dr,9);   write('  Move block             Ctrl-K Ctrl-V  ->  ');
  277.   gotoxy(dr,10);  write('  Delete block           Ctrl-K Ctrl-Y  ->  ');
  278.   gotoxy(dr,11);  write('  Read block from disk   Ctrl-K Ctrl-R  ->  ');
  279.   gotoxy(dr,12);  write('  Write block to disk    Ctrl-K Ctrl-W  ->  ');
  280.   Wait;
  281. end;
  282.  
  283. procedure MiscEditing;
  284. begin
  285.   gotoxy(dr,1);   write('MISC. EDITING COMMANDS :');
  286.   gotoxy(dr,2);   write('  End edit               Ctrl-K Ctrl-D  ->  ');
  287.   gotoxy(dr,3);   write('  Tab                    Ctrl-I         ->  Tab');
  288.   gotoxy(dr,4);   write('  Auto tab on/off        Ctrl-Q Ctrl-I  ->  ');
  289.   gotoxy(dr,5);   write('  Restore line           Ctrl-Q Ctrl-L  ->  ');
  290.   gotoxy(dr,6);   write('  Find                   Ctrl-Q Ctrl-F  ->  ');
  291.   gotoxy(dr,7);   write('  Find and Replace       Ctrl-Q Ctrl-A  ->  ');
  292.   gotoxy(dr,8);   write('  Repeat last find       Ctrl-L         ->  ');
  293.   gotoxy(dr,9);   write('  Control char prefix    Ctrl-P         ->  ');
  294.   gotoxy(dr,10);  write('  Abort operation        Ctrl-U         ->  ');
  295.   gotoxy(dr,11);  write('OPTIONS :');
  296.   gotoxy(dr,12);  write('  B - Backwards        U - Ignore upper/lowercase');
  297.   gotoxy(dr,13);  write('  G - Global           W - Whole words only');
  298.   gotoxy(dr,14);  write('  N - No qestions      n - Number of occurences');
  299.   Wait;
  300. end;
  301.  
  302. procedure PrintType;
  303. begin
  304.   gotoxy(dr,2);   write('{ integer, real, boolean, char, string[xx] }');
  305.   gotoxy(dr,4);   write('TYPE');
  306.   gotoxy(dr,5);   write('  text80   = STRING[80];');
  307.   gotoxy(dr,6);   write('  letter   = ''a''..''z'';');
  308.   gotoxy(dr,7);   write('  tones    = 1..12;');
  309.   gotoxy(dr,8);   write('  row      = SET OF tones;');
  310.   gotoxy(dr,9);   write('  chtype   = char;');
  311.   gotoxy(dr,10);  write('  regtype  = record');
  312.   gotoxy(dr,11);  write('               ax,bx,cx,dx,bp,si,di,ds,es,flags:INTEGER');
  313.   gotoxy(dr,12);  write('             end;');
  314.   gotoxy(dr,13);  write('  day      = (monday,tuesday,wenesday,thursday,');
  315.   gotoxy(dr,14);  write('              friday,saturday,sunday);');
  316.   Wait;
  317. end;
  318.  
  319. procedure PrintConst;
  320. begin
  321.   gotoxy(dr,2);   write('{ stored in code_segment }');
  322.   gotoxy(dr,3);   write('{ integer, real, boolean, char, string[xx] }');
  323.   gotoxy(dr,5);   write('CONST');
  324.   gotoxy(dr,6);   write('  minus2     = -2;');
  325.   gotoxy(dr,7);   write('  pagesize   = 60;');
  326.   gotoxy(dr,8);   write('  pi         = 3.1415926535;');
  327.   gotoxy(dr,9);   write('  histring   = ''hello'';');
  328.   gotoxy(dr,10);  write('  valid      = TRUE;');
  329.   gotoxy(dr,11);  write('  msb : BYTE = 0;');
  330.   gotoxy(dr,12);  write('  lsb : BYTE = 0;');
  331.   Wait;
  332. end;
  333.  
  334. procedure PrintVar;
  335. begin
  336.   gotoxy(dr,2);   write('{ stored in data_segment }');
  337.   gotoxy(dr,3);   write('{ integer, real, boolean, char, string[xx] }');
  338.   gotoxy(dr,4);   write('VAR');
  339.   gotoxy(dr,5);   write('  count,index    : INTEGER;');
  340.   gotoxy(dr,6);   write('  result,value   : REAL;');
  341.   gotoxy(dr,7);   write('  eom,character  : CHAR;');
  342.   gotoxy(dr,8);   write('  line           : STRING[80];');
  343.   gotoxy(dr,9);   write('  error          : BOOLEAN;');
  344.   gotoxy(dr,10);  write('  inventory      : FILE OF invtype;');
  345.   gotoxy(dr,11);  write('  matrix         : ARRAY [1..50,1..50] OF INTEGER;');
  346.   gotoxy(dr,12);  write('  cmdlength      : BYTE ABSOLUTE CSEG:$0080;');
  347.   gotoxy(dr,13);  write('  cmdline        : STRING[127] ABSOLUTE CSEG:$0080;');
  348.   gotoxy(dr,14);  write('  intrip         : INTEGER ABSOLUTE $0000:$0040;');
  349.   Wait;
  350. end;
  351.  
  352. procedure PrintCase;
  353. begin
  354.   gotoxy(dr,2);   write('WITH record_identifier DO');
  355.   gotoxy(dr,3);   write('  statement;');
  356.   gotoxy(dr,6);   write('CASE expression OF');
  357.   gotoxy(dr,7);   write('  constant  :  statement;');
  358.   gotoxy(dr,8);   write('  constant  :  statement');
  359.   gotoxy(dr,9);   write('ELSE');
  360.   gotoxy(dr,10);  write('  statement;');
  361.   gotoxy(dr,11);  write('  statement');
  362.   gotoxy(dr,12);  write('END;');
  363.   Wait;
  364. end;
  365.  
  366. procedure RepeatWhile;
  367. begin
  368.   gotoxy(dr,4);   write('REPEAT');
  369.   gotoxy(dr,5);   write('  statement;');
  370.   gotoxy(dr,6);   write('  statement ');
  371.   gotoxy(dr,7);   write('UNTIL condition;');
  372.   gotoxy(dr,10);  write('WHILE condition DO');
  373.   gotoxy(dr,11);  write('  statement;');
  374.   Wait;
  375. end;
  376.  
  377. procedure IfFor;
  378. begin
  379.   gotoxy(dr,2);   write('IF condition');
  380.   gotoxy(dr,3);   write('  THEN statement');
  381.   gotoxy(dr,4);   write('  ELSE statement;');
  382.   gotoxy(dr,7);   write('FOR variable := expression1 TO expression2 DO');
  383.   gotoxy(dr,8);   write('  statement;');
  384.   gotoxy(dr,10);  write('                      or');
  385.   gotoxy(dr,12);  write('FOR variable := expression1 DOWNTO expression2 DO');
  386.   gotoxy(dr,13);  write('  statement;');
  387.   Wait;
  388. end;
  389.  
  390. procedure ProgProcFunc;
  391. begin
  392.   gotoxy(dr,4);   write('PROGRAM progname;');
  393.   gotoxy(dr,7);   write('PROCEDURE procname(VAR num1,num2 : INTEGER; ch : CHAR);');
  394.   gotoxy(dr,8);   write('PROCEDURE procname(str1 : STRING80; length : REAL);');
  395.   gotoxy(dr,11);  write('FUNCTION funcname(VAR value : REAL) : INTEGER;');
  396.   gotoxy(dr,12);  write('FUNCTION funcname(ch : CHAR; num : INTEGER) : STRING80;');
  397.   Wait;
  398. end;
  399.  
  400. procedure ProgramStructure;
  401. begin
  402.   gotoxy(dr,1);   write('PROGRAM programname;');
  403.   gotoxy(dr,2);   write('type');
  404.   gotoxy(dr,3);   write('  .....');
  405.   gotoxy(dr,4);   write('const');
  406.   gotoxy(dr,5);   write('  .....');
  407.   gotoxy(dr,6);   write('var');
  408.   gotoxy(dr,7);   write('  .....');
  409.   gotoxy(dr,8);   write('PROCEDURE procedurename(variable_list);');
  410.   gotoxy(dr,9);   write('  .....');
  411.   gotoxy(dr,10);  write('FUNCTION functionname(variable_list):type_identifier;');
  412.   gotoxy(dr,11);  write('  .....');
  413.   gotoxy(dr,12);  write('begin');
  414.   gotoxy(dr,13);  write('  .....');
  415.   gotoxy(dr,14);  write('end.');
  416.   Wait;
  417. end;
  418.  
  419. procedure InputOutput;
  420. begin
  421.   gotoxy(dr,1);   write('INPUT/OUTPUT PROCEDURES :');
  422.   gotoxy(dr,2);   write('  Read(var F:file of type;var v:type);');
  423.   gotoxy(dr,3);   write('  Read(var F:text;var I:Integer);');
  424.   gotoxy(dr,4);   write('  Read(var F:text;var R:Real);');
  425.   gotoxy(dr,5);   write('  Read(var F:text;var C:Char);');
  426.   gotoxy(dr,6);   write('  Read(var F:text;var S:string);');
  427.   gotoxy(dr,7);   write('  Readln(var F:text);');
  428.   gotoxy(dr,8);   write('  Write(var F:file of type;var v:type);');
  429.   gotoxy(dr,9);   write('  Write(var F:text;I:Integer);');
  430.   gotoxy(dr,10);  write('  Write(var F:text;R:Real);');
  431.   gotoxy(dr,11);  write('  Write(var F:text;B:Boolean);');
  432.   gotoxy(dr,12);  write('  Write(var F:text;C:Char);');
  433.   gotoxy(dr,13);  write('  Write(var F:text;S:string);');
  434.   gotoxy(dr,14);  write('  Writeln(var F:text);');
  435.   Wait;
  436. end;
  437.  
  438. procedure Arithmetic;
  439. begin
  440.   gotoxy(dr,2);   write('ARITHMETIC FUNCTIONS :');
  441.   gotoxy(dr,3);   write('  Abs(I:Integer):Integer;');
  442.   gotoxy(dr,4);   write('  Abs(R:Real):Real;');
  443.   gotoxy(dr,5);   write('  ArcTan(R:Real):Real;');
  444.   gotoxy(dr,6);   write('  Cos(R:Real):Real;');
  445.   gotoxy(dr,7);   write('  Exp(R:Real):Real;');
  446.   gotoxy(dr,8);   write('  Frac(R:Real):Real;');
  447.   gotoxy(dr,9);   write('  Int(R:Real):Real;');
  448.   gotoxy(dr,10);  write('  Ln(R:Real):Real;');
  449.   gotoxy(dr,11);  write('  Sin(R:Real):Real;');
  450.   gotoxy(dr,12);  write('  Sqr(I:Integer):Integer;');
  451.   gotoxy(dr,13);  write('  Sqr(R:Real):Real;');
  452.   gotoxy(dr,14);  write('  Sqrt(R:Real):Real;');
  453.   Wait;
  454. end;
  455.  
  456. procedure ScalarHeap;
  457. begin
  458.   gotoxy(dr,2);   write('SCALAR FUNCTIONS :');
  459.   gotoxy(dr,3);   write('  Odd(I:Integer):Boolean;');
  460.   gotoxy(dr,4);   write('  Pred(X:scalar):scalar;');
  461.   gotoxy(dr,5);   write('  Succ(X:scalar):scalar;');
  462.   gotoxy(dr,6);   write('HEAP CONTROL PROCEDURES :');
  463.   gotoxy(dr,7);   write('  GetMem(var P:pointer;I:Integer);');
  464.   gotoxy(dr,8);   write('  Mark(var P:pointer);');
  465.   gotoxy(dr,9);   write('  New(var P:pointer);');
  466.   gotoxy(dr,10);  write('  Release(var P:pointer);');
  467.   gotoxy(dr,11);  write('HEAP CONTROL FUNCTIONS :');
  468.   gotoxy(dr,12);  write('  MemAvail:Integer;');
  469.   gotoxy(dr,13);  write('  Ord(P:pointer):Integer;');
  470.   gotoxy(dr,14);  write('  Ptr(I:Integer):pointer;');
  471.   Wait;
  472. end;
  473.  
  474. procedure Strings;
  475. begin
  476.   gotoxy(dr,2);   write('STRING PROCEDURES :');
  477.   gotoxy(dr,3);   write('  Delete(var S:string;Pos,Len:Integer);');
  478.   gotoxy(dr,4);   write('  Insert(S:string;var D:string;Pos:Integer);');
  479.   gotoxy(dr,5);   write('  Str(I:Integer;var S:string);');
  480.   gotoxy(dr,6);   write('  Str(R:Real;var S:string);');
  481.   gotoxy(dr,7);   write('  Val(S:string;var R:Real;var p:Integer);');
  482.   gotoxy(dr,8);   write('  Val(S:string;var I,P:Integer);');
  483.   gotoxy(dr,9);   write('STRING FUNCTIONS :');
  484.   gotoxy(dr,10);  write('  Concat(S1,S2,...,Sn:string):string;');
  485.   gotoxy(dr,11);  write('  Copy(S:string;Pos,Len:Integer):string;');
  486.   gotoxy(dr,12);  write('  Length(S:string):Integer;');
  487.   gotoxy(dr,13);  write('  Pos(Pattern,Source:string):Integer;');
  488.   Wait;
  489. end;
  490.  
  491. procedure FileProc;
  492. begin
  493.   gotoxy(dr,2);   write('FILE PROCEDURES :');
  494.   gotoxy(dr,3);   write('  Assign(var F:file;name:string);');
  495.   gotoxy(dr,4);   write('  BlockRead(var F:file;var Dest:Type;Num:Integer);');
  496.   gotoxy(dr,5);   write('  BlockWrite(var F:file;var Dest:Type;Num:Integer);');
  497.   gotoxy(dr,6);   write('  Chain(var F:file);');
  498.   gotoxy(dr,7);   write('  Close(var F:file);');
  499.   gotoxy(dr,8);   write('  Erase(var F:file);');
  500.   gotoxy(dr,9);   write('  Execute(var F:file);');
  501.   gotoxy(dr,10);  write('  Rename(var F:file;Name:string);');
  502.   gotoxy(dr,11);  write('  Reset(var F:file);');
  503.   gotoxy(dr,12);  write('  Rewrite(var F:file);');
  504.   gotoxy(dr,13);  write('  Seek(var F:file of type;Pos:Integer);');
  505.   Wait;
  506. end;
  507.  
  508. procedure FileFunc;
  509. begin
  510.   gotoxy(dr,2);   write('FILE FUNCTIONS :');
  511.   gotoxy(dr,3);   write('  Eof(var F:file):Boolean;');
  512.   gotoxy(dr,4);   write('  Eoln(var F:Text):Boolean;');
  513.   gotoxy(dr,5);   write('  FilePos(var F:file of type):Integer;');
  514.   gotoxy(dr,6);   write('  FilePos(var F:file):Integer;');
  515.   gotoxy(dr,7);   write('  FileSize(var F:file of type):Integer;');
  516.   gotoxy(dr,8);   write('  FileSize(var F:file):Integer;');
  517.   Wait;
  518. end;
  519.  
  520. procedure TransferScreen;
  521. begin
  522.   gotoxy(dr,1);   write('TRANSFER FUNCTIONS :');
  523.   gotoxy(dr,2);   write('  Chr(I:Integer):Char;');
  524.   gotoxy(dr,3);   write('  Ord(X:scalar):Integer;');
  525.   gotoxy(dr,4);   write('  Round(R:Real):Integer;');
  526.   gotoxy(dr,5);   write('  Trunc(R:Real):Integer;');
  527.   gotoxy(dr,6);   write('SCREEN RELATED PROCEDURES :');
  528.   gotoxy(dr,7);   write('  CrtExit;');
  529.   gotoxy(dr,8);   write('  CrtInit;');
  530.   gotoxy(dr,9);   write('  ClrEol;');
  531.   gotoxy(dr,10);  write('  ClrScr;');
  532.   gotoxy(dr,11);  write('  DelLine;');
  533.   gotoxy(dr,12);  write('  GotoXY(X,Y:Integer);');
  534.   gotoxy(dr,13);  write('  InsLine;');
  535.   gotoxy(dr,14);  write('  LowVideo;');
  536.   gotoxy(dr,15);  write('  NormVideo;');
  537.   Wait;
  538. end;
  539.  
  540. procedure MiscProc;
  541. begin
  542.   gotoxy(dr,1);   write('MISCELLANEOUS PROCEDURES :');
  543.   gotoxy(dr,2);   write('  Bdos(func,param:Integer);');
  544.   gotoxy(dr,3);   write('  Bios(func,param:Integer);');
  545.   gotoxy(dr,4);   write('  Delay(mS:Integer);');
  546.   gotoxy(dr,5);   write('  FillChar(var dest;length:Integer;data:Char);');
  547.   gotoxy(dr,6);   write('  FillChar(var dest;length:Integer;data:Byte);');
  548.   gotoxy(dr,7);   write('  Halt;');
  549.   gotoxy(dr,8);   write('  Move(var source,dest;length:Integer);');
  550.   gotoxy(dr,9);   write('  Randomize;');
  551.   gotoxy(dr,10);  write('  Inline($CD/$10);');
  552.   gotoxy(dr,11);  write('  Intr(intrnum:Integer;regs:Regtype);');
  553.   gotoxy(dr,12);  write('MISCELLANEOUS FUNCTIONS Part I :');
  554.   gotoxy(dr,13);  write('  Addr(var variable):Integer;');
  555.   gotoxy(dr,14);  write('  Addr(<function identifier>):Integer;');
  556.   gotoxy(dr,15);  write('  Addr(<procedure identifier>):Integer;');
  557.   Wait;
  558. end;
  559.  
  560. procedure MiscFunc;
  561. begin
  562.   gotoxy(dr,1);   write('MISCELLANEOUS FUNCTIONS Part II :');
  563.   gotoxy(dr,2);   write('  Bdos(Func,Param:Integer):Byte;');
  564.   gotoxy(dr,3);   write('  BdosHL(Func,Param:Integer):Integer;');
  565.   gotoxy(dr,4);   write('  Bios(Func,Param:Integer):Byte;');
  566.   gotoxy(dr,5);   write('  BiosHL(Func,Param:Integer):Integer');
  567.   gotoxy(dr,6);   write('  Hi(I:Integer):Integer;');
  568.   gotoxy(dr,7);   write('  IOresult:Boolean;');
  569.   gotoxy(dr,8);   write('  KeyPressed:Boolean;');
  570.   gotoxy(dr,9);   write('  Lo(I:Integer):Integer;');
  571.   gotoxy(dr,10);  write('  Random(Range:Integer):Integer;');
  572.   gotoxy(dr,11);  write('  Random:Real;');
  573.   gotoxy(dr,12);  write('  SizeOf(var variable):Integer;');
  574.   gotoxy(dr,13);  write('  SizeOf(<type identifier>):Integer;');
  575.   gotoxy(dr,14);  write('  Swap(I:Integer):Integer;');
  576.   gotoxy(dr,15);  write('  Upcase(Ch:Char):Char;');
  577.   Wait;
  578. end;
  579.  
  580. procedure PrintDirectives;
  581. begin
  582.   gotoxy(dr,1);   write('COMPILER DIRECTIVES :');
  583.   gotoxy(dr,2);   write('  B - I/O Mode Selection          [ default B+ ]');
  584.   gotoxy(dr,3);   write('  C - CNTL S and CNTL C           [ default C+ ]');
  585.   gotoxy(dr,4);   write('  I - I/O Error Handling          [ default I+ ]');
  586.   gotoxy(dr,5);   write('  I - Include Files');
  587.   gotoxy(dr,6);   write('  R - Index Range Check           [ default R- ]');
  588.   gotoxy(dr,7);   write('  V - Var-parameter Type Checking [ default V+ ]');
  589.   gotoxy(dr,8);   write('  U - User Interupt               [ default U- ]');
  590.   gotoxy(dr,9);   write('  K - Stack Checking              [ default K+ ]');
  591.   gotoxy(dr,10);  write('  examples  :');
  592.   gotoxy(dr,11);  write('    {$I-}');
  593.   gotoxy(dr,12);  write('    {$I INCLUDE.FIL}');
  594.   gotoxy(dr,13);  write('    {$B-,R+,V-}');
  595.   gotoxy(dr,14);  write('    (*$U+*)');
  596.   Wait;
  597. end;
  598.  
  599. procedure RuntimeErrors;
  600. begin
  601.   gotoxy(dr,2);   write('RUN-TIME ERROR MESSAGES :');
  602.   gotoxy(dr,3);   write('  01  -  Floating point overflow.');
  603.   gotoxy(dr,4);   write('  02  -  Division by zero attempted.');
  604.   gotoxy(dr,5);   write('  03  -  Sqrt argument error.');
  605.   gotoxy(dr,6);   write('  04  -  Ln argument error.');
  606.   gotoxy(dr,7);   write('  10  -  String length error.');
  607.   gotoxy(dr,8);   write('  11  -  Invalid string index.');
  608.   gotoxy(dr,9);   write('  90  -  Index out of range.');
  609.   gotoxy(dr,10);  write('  91  -  Scalar or subrange out of range.');
  610.   gotoxy(dr,11);  write('  92  -  Out of integer range.');
  611.   gotoxy(dr,12);  write('  FF  -  Heap/stack collision.');
  612.   Wait;
  613. end;
  614.  
  615. procedure IOErrors;
  616. begin
  617.   gotoxy(dr,1);   write('I/O ERROR MESSAGES :');
  618.   gotoxy(dr,2);   write('  01  -  File does not exist.');
  619.   gotoxy(dr,3);   write('  02  -  File not open for input.');
  620.   gotoxy(dr,4);   write('  03  -  File not open for output.');
  621.   gotoxy(dr,5);   write('  04  -  File not open.');
  622.   gotoxy(dr,6);   write('  10  -  Error in numeric format.');
  623.   gotoxy(dr,7);   write('  20  -  Operation not allowed on a logical device.');
  624.   gotoxy(dr,8);   write('  21  -  Not allowed in direct mode.');
  625.   gotoxy(dr,9);   write('  22  -  Assign to std files not allowed.');
  626.   gotoxy(dr,10);  write('  90  -  Record length mismatch.');
  627.   gotoxy(dr,11);  write('  91  -  Seek beyond end-of-file.');
  628.   gotoxy(dr,12);  write('  99  -  Unexpected end-of-file.');
  629.   gotoxy(dr,13);  write('  F0  -  Disk write error.');
  630.   gotoxy(dr,14);  write('  F1  -  Directory is full.');
  631.   gotoxy(dr,15);  write('  F2  -  File size overflow.   FF  -  File disappeared.');
  632.   Wait;
  633. end;
  634.  
  635. procedure StdIdentifiers;
  636. begin
  637.   gotoxy(dr,2);   write('STANDARD IDENTIFIERS :');
  638.   gotoxy(dr,3);   write('  DSeg:Integer');
  639.   gotoxy(dr,4);   write('  CSeg:Integer');
  640.   gotoxy(dr,5);   write('  SSeg:Integer');
  641.   gotoxy(dr,6);   write('  Seg(Name):Integer');
  642.   gotoxy(dr,7);   write('  Addr(Name):pointer');
  643.   gotoxy(dr,8);   write('  Ofs(Name):Integer');
  644.   gotoxy(dr,9);   write('  Mem[segment:offset]');
  645.   gotoxy(dr,10);  write('  MemW[segment:offset]');
  646.   gotoxy(dr,11);  write('  Port[portnum]');
  647.   gotoxy(dr,12);  write('  PortW[portnum]');
  648.   gotoxy(dr,13);  write('  LongFilePos       LongFileSize');
  649.   gotoxy(dr,14);  write('  LongSeek          MsDos');
  650.   Wait;
  651. end;
  652.  
  653. procedure Version2I;
  654. begin
  655.   gotoxy(dr,2);   write('VERSION 2 Part I ');
  656.   gotoxy(dr,3);   write('  Procedures Part I :');
  657.   gotoxy(dr,4);   write('    Dispose(var P:pointer);');
  658.   gotoxy(dr,5);   write('    Draw(X1,Y1,X2,Y2,Color:Integer);');
  659.   gotoxy(dr,6);   write('    FreeMem(var P:pointer,I:Integer);');
  660.   gotoxy(dr,7);   write('    GraphBackground(Color:Integer);');
  661.   gotoxy(dr,8);   write('    GraphColorMode;');
  662.   gotoxy(dr,9);   write('    GraphMode;');
  663.   gotoxy(dr,10);  write('    GraphWindow(X1,Y1,X2,Y2,Color:Integer);');
  664.   gotoxy(dr,11);  write('    HiRes;');
  665.   gotoxy(dr,12);  write('    HiResColor(Color:Integer);');
  666.   gotoxy(dr,13);  write('    NoSound;');
  667.   gotoxy(dr,14);  write('    Palette(Color:Integer);');
  668.   Wait;
  669. end;
  670.  
  671. procedure Version2II;
  672. begin
  673.   gotoxy(dr,2);   write('VERSION 2 Part II');
  674.   gotoxy(dr,3);   write('  Procedures Part II :');
  675.   gotoxy(dr,4);   write('    Plot(X,Y,Color:Integer);');
  676.   gotoxy(dr,5);   write('    Sound(I:Integer);');
  677.   gotoxy(dr,6);   write('    TextBackground(Color:Integer);');
  678.   gotoxy(dr,7);   write('    TextColor(Color:Integer);');
  679.   gotoxy(dr,8);   write('    TextMode(Color:Integer);');
  680.   gotoxy(dr,9);   write('    Window(X1,Y1,X2,Y2,Color:Integer);');
  681.   gotoxy(dr,10);  write('  Functions :');
  682.   gotoxy(dr,11);  write('    MaxAvail:Integer;');
  683.   gotoxy(dr,12);  write('    WhereX:Integer;');
  684.   gotoxy(dr,13);  write('    WhereY:Integer;');
  685.   Wait;
  686. end;
  687.  
  688.  
  689.  
  690. { MAIN INTERUPT SERVICE PROCEDURES }
  691.  
  692.  
  693. procedure EditCommands;
  694. begin
  695.   repeat
  696.     PrintMenu(1);
  697.     case selection of
  698.       1 : CursorMoveI;
  699.       2 : CursorMoveII;
  700.       3 : InsertDelete;
  701.       4 : BlockCommands;
  702.       5 : MiscEditing;
  703.     end;
  704.     until selection = escape;
  705.     selection := 10;
  706. end;
  707.  
  708. procedure Syntax;
  709. begin
  710.   repeat
  711.     PrintMenu(2);
  712.     case selection of
  713.       1 : PrintType;
  714.       2 : PrintConst;
  715.       3 : PrintVar;
  716.       4 : PrintCase;
  717.       5 : RepeatWhile;
  718.       6 : IfFor;
  719.       7 : ProgProcFunc;
  720.       8 : ProgramStructure;
  721.     end;
  722.     until selection = escape;
  723.     selection := 10;
  724. end;
  725.  
  726. procedure ProcFunc;
  727. begin
  728.   repeat
  729.     PrintMenu(3);
  730.     case selection of
  731.       1 : InputOutput;
  732.       2 : Arithmetic;
  733.       3 : ScalarHeap;
  734.       4 : Strings;
  735.       5 : FileProc;
  736.       6 : FileFunc;
  737.       7 : TransferScreen;
  738.       8 : MiscProc;
  739.       9 : MiscFunc;
  740.     end;
  741.     until selection = escape;
  742.     selection := 10;
  743.  
  744. end;
  745.  
  746. procedure DOIT;
  747. begin
  748.   textcolor(7);
  749.   repeat
  750.     PrintMenu(0);
  751.     case selection of
  752.       1 : EditCommands;
  753.       2 : Syntax;
  754.       3 : ProcFunc;
  755.       4 : PrintDirectives;
  756.       5 : RuntimeErrors;
  757.       6 : IOErrors;
  758.       7 : StdIdentifiers;
  759.       8 : Version2I;
  760.       9 : Version2II;
  761.     end;
  762.   until selection = escape;
  763. end;
  764.  
  765.  
  766. procedure ProcessInt;                  { Start of interupt service }
  767. begin
  768. {when invoked, this procedure saves the registers into the structured constant
  769.  'REGS' and restores the ds from the previously saved integer constant 'saveds'}
  770.  
  771.     inline(
  772.     $53/                               {PUSH BX}
  773.     $BB/regs/                          {MOV BX,OFFSET REGS}
  774.     $2E/$89/$47/$00/                   {CS:MOV [BX]0,AX}
  775.     $58/                               {POP AX}
  776.     $2E/$89/$47/$02/                   {CS:MOV [BX]2,AX}
  777.     $2E/$89/$4F/$04/                   {CS:MOV [BX]4,CX}
  778.     $2E/$89/$57/$06/                   {CS:MOV [BX]6,DX}
  779.     $2E/$89/$6F/$08/                   {CS:MOV [BX]8,BP}
  780.     $2E/$89/$77/$0A/                   {CS:MOV [BX]A,SI}
  781.     $2E/$89/$7F/$0C/                   {CS:MOV [BX]C,DI}
  782.     $2E/$8C/$5F/$0E/                   {CS:MOV [BX]E,DS}
  783.     $2E/$8C/$47/$10/                   {CS:MOV [BX]10,ES}
  784.     $9C/                               {PUSHF}
  785.     $58/                               {POP AX}
  786.     $2E/$89/$47/$12/                   {CS:MOV [BX]12,AX}
  787.     $2E/$8E/$1E/saveds                 {CS:MOV DS,SAVEDS -- PUT PROPER DS}
  788.     );
  789.  
  790.   if halfreg.ah <> 0 then Intr(userint,regs) else
  791.   begin
  792.     Intr(userint,regs);
  793.     if (halfreg.ah = EntryChar) and (halfreg.al = $00) then
  794.     begin
  795.       savereg.ax := $0300;
  796.       savereg.bx := $0;
  797.       Intr($10,savereg);               { get cursor position }
  798.       cursorpos := savereg.dx;
  799.  
  800.       OpenWindow;                      { save text in window }
  801.       DOIT;
  802.       CloseWindow;                     { put back the text in the window }
  803.  
  804.       savereg.ax := $0200;
  805.       savereg.bx := $0;
  806.       savereg.dx := cursorpos;
  807.       Intr($10,savereg);               { restore cursor position }
  808.  
  809.       halfreg.ah := 0;
  810.       Intr(userint,regs);
  811.     end;
  812.   end;
  813.  
  814. {when invoked this routine restores the registers from the structure constant}
  815.  
  816.     inline(
  817.     $BB/REGS/                          {MOV BX,OFFSET REGS}
  818.     $2E/$8E/$47/$10/                   {CS:MOV ES,[BX]10}
  819.     $2E/$8E/$5F/$0E/                   {CS:MOV DS,[BX]0E}
  820.     $2E/$8B/$7F/$0C/                   {CS:MOV DI,[BX]0C}
  821.     $2E/$8B/$77/$0A/                   {CS:MOV SI,[BX]0A}
  822.     $2E/$8B/$6F/$08/                   {CS:MOV BP,[BX]08}
  823.     $2E/$8B/$57/$06/                   {CS:MOV DX,[BX]06}
  824.     $2E/$8B/$4F/$04/                   {CS:MOV CX,[BX]04}
  825.     $2E/$8B/$47/$00/                   {CS:MOV AX,[BX]00}
  826.     $2E/$FF/$77/$12/                   {CS:PUSH [BX]12}
  827.     $9D/                               {POPF}
  828.     $2E/$8B/$5F/$02/                   {CS:MOV BX,[BX]02}
  829.     $5D/                               {POP BP}  {restore the stack pointer}
  830.     $5D                                {POP BP}
  831.  
  832.     );
  833.  
  834.     inline ($CA/$02/$00)               {RETF 02}
  835.  
  836. end;
  837.  
  838.  
  839. { PROGRAM 'THELP' }                    { Program installation }
  840. begin
  841.   SaveDS := dseg;
  842.   SaveReg.ax := $3500 + UserInt;
  843.   Intr($21,SaveReg);                   { get user interupt }
  844.  
  845.   if SaveReg.es <> $00 then
  846.     writeln('User Interupt in use -- cant install THELP.')
  847.   else
  848.  
  849.   begin
  850.     writeln('Installing THELP  --  Press < ALT "R" > to Recall help.');
  851.     writeln('           
  852.     savereg.ax := $3500 + KybdInt;
  853.     Intr($21,savereg);                 { get keyboard interupt }
  854.  
  855.     savereg.ax := $2500 + UserInt;
  856.     savereg.ds := savereg.es;
  857.     savereg.dx := savereg.bx;
  858.     Intr($21,savereg);                 { put in user interupt }
  859.  
  860.     savereg.ax := $2500 + KybdInt;
  861.     savereg.ds := cseg;
  862.     savereg.dx := ofs(ProcessInt);
  863.     Intr($21,savereg);                 { install our interupt processor }
  864.  
  865.     savereg.dx := ProgSize;
  866.     Intr($27,savereg);                 { terminate and stay resident }
  867.   end;
  868.   inline($CD/$20);                     { terminate if interupt in use }
  869. end.
  870.  
  871.  
  872. Key <ENTER> to continue: esident }
  873.   end;
  874.   inline(